// 数字人管理——形象展示
import request from '@/utils/request';
import {object2Url} from "@/utils/trans";

// 字幕转mp3接口
export async function getSubmitAudioProduceJob2(data) {
  const res = await request.post('/business/imageTask/submitAudio', data);
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

export async function getSubmitAudioProduceJob (text) {
  const ts = new Date().getTime()
  const ua = navigator.userAgent
  const us = {
    ts,
    ua,
    text:text
  }
  let url = `/business/imageTask/submitAudio${object2Url(us)}`
  const res = await request.get(url, us)
  if (res.data.code === 2000) {
    return res.data.data
  }
  return Promise.reject(new Error(res.data.msg))
}


/*查看形象分页*/
export async function queryImagePage(data) {
  const res = await request.post('/business/image/page', data);
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}


/*添加形象*/
export async function addImages(data) {
  const res = await request.post('/business/image/save', data);
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}


export async function createTask(data) {
  const res = await request.post('/business/imageTask/createTask', data);
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

// 获取数字人AI人声——创建任务使用
export async function getAiList () {
  const ts = new Date().getTime()
  const ua = navigator.userAgent
  const us = {
    ts,
    ua
  }
  let url = `/business/imageTask/getSound${object2Url(us)}`
  const res = await request.get(url, us)
  if (res.data.code === 2000) {
    return res.data.data
  }
  return Promise.reject(new Error(res.data.msg))
}


